
(function(window, $, layui) {
    layui.config({
        base: 'js/',
        version: '1.0'
    })
    layui.use('oka', function(){
    });

    Function.prototype.optimizeFn = function(time) {
        if (time == 0)
            return this;
        var _fn = this, _t = time, _task;
        return function() {
            var self = this, fn = _fn, t = _t, task = _task, _args = arguments;
            if (task == undefined) {
                _task = task = setTimeout(function() {
                    fn.apply(self,_args);
                    _task = undefined;
                    _args = self = task = fn = null;
                }, t);
            }

        };
    };
    $(document).ready(function(){
        var resize = function() {
            $('[name="ifames"]').each(function(){
                console.log(111)
                $(this).css("height",($("#container")[0].clientHeight-46) + "px");
            })

        };
        resize = resize.optimizeFn(300);
        $(window).resize(function() {
            resize();
        });
        var addRippleEffect = function(e) {
            // console.log(e);
            layui.stope(e)
            var target = e.target;
            if (target.localName !== 'a') return false;
            var rect = target.getBoundingClientRect();
            var ripple = target.querySelector('.ripple');
            if (!ripple) {
                ripple = document.createElement('span');
                ripple.className = 'ripple'
                ripple.style.height = ripple.style.width = Math.max(rect.width, rect.height) + 'px'
                target.appendChild(ripple);
            }
            ripple.classList.remove('show');
            var top = e.pageY - rect.top - ripple.offsetHeight / 2 - document.body.scrollTop;
            var left = e.pageX - rect.left - ripple.offsetWidth / 2 - document.body.scrollLeft;
            ripple.style.top = top + 'px'
            ripple.style.left = left + 'px'
            ripple.classList.add('show');
            return false;
        }
        document.addEventListener('click', addRippleEffect, false);
    });
})(window, jQuery, layui);
